const {
    ipcRenderer
} = require('electron')


var funcId = 0;
var funcMap = {};

ipcRenderer.on('workComplete', function(sender, funcId, destPath) {
    funcMap[funcId][0](destPath);
    funcMap[funcId] = null;
})

ipcRenderer.on('workFail', function(sender, funcId, errorMsg) {
    funcMap[funcId][1](errorMsg);
    funcMap[funcId] = null;
})

exports.openDialog = function(whiteList, workdays, selectMonthStr, callback, failCallback) {
    funcMap[++funcId] = [callback, failCallback];
    ipcRenderer.send('selectFile', funcId, whiteList, workdays, selectMonthStr)
}